/*
 * Created: 2024/7/4
 * Author:  hineven
 * See LICENSE for licensing.
 */

#ifndef MIRENDERER_CORE_TYPES_H
#define MIRENDERER_CORE_TYPES_H

#include "core/common.h"
MI_NAMESPACE_BEGIN

enum class ThreadPerformanceType {
    kHigh,
    kLow,
    kMax
};

// The type of threads in the renderer.
// There are only 2 threads in the renderer, and they are performance sensitive, so please allocate them to large cores
// if possible.
enum class RendererThreadType {
    // A single thread interacting directly with graphics APIs.
    kRHI,
    // The main thread performing all the rendering stuff like scene traverse, RDG recording, etc.
    kRender,
    kMax
};

// Types from render resources
enum class LightType {
    // Directional light (sunshine)
    kDirectional,
    // Skylight
    kInfinite,
    // Point light
    kPoint,
    // Area lights (meshed lights)
    kArea,
    kMax
};

#define MAKE_FLAGS(FlagName) \
struct FlagName##Flags { \
    uint32_t flags; \
    FORCEINLINE FlagName##Flags() : flags(0) {} \
    FORCEINLINE FlagName##Flags(FlagName##FlagBits flag) : flags(static_cast<uint32_t>(flag)) {}  \
    FORCEINLINE FlagName##Flags(uint32_t flags) : flags(flags) {}  \
    FORCEINLINE operator bool() const { return flags != 0; }  \
    FORCEINLINE bool operator==(FlagName##Flags other) const { return flags == other.flags; } \
    FORCEINLINE bool operator!=(FlagName##Flags other) const { return flags != other.flags; } \
}; \
FORCEINLINE FlagName##Flags operator|(FlagName##FlagBits a, FlagName##FlagBits b) { \
    return static_cast<FlagName##Flags>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b)); \
} \
FORCEINLINE FlagName##Flags operator&(FlagName##FlagBits a, FlagName##FlagBits b) { \
    return static_cast<FlagName##Flags>(static_cast<uint32_t>(a) & static_cast<uint32_t>(b)); \
} \
FORCEINLINE FlagName##Flags operator|(FlagName##Flags a, FlagName##FlagBits b) { \
    return static_cast<FlagName##Flags>(a | static_cast<uint32_t>(b)); \
} \
FORCEINLINE FlagName##Flags operator&(FlagName##Flags a, FlagName##FlagBits b) { \
    return static_cast<FlagName##Flags>(a & static_cast<uint32_t>(b)); \
} \
FORCEINLINE FlagName##Flags operator|(FlagName##FlagBits a, FlagName##Flags b) { \
    return static_cast<FlagName##Flags>(static_cast<uint32_t>(a) | b); \
} \
FORCEINLINE FlagName##Flags operator&(FlagName##FlagBits a, FlagName##Flags b) { \
    return static_cast<FlagName##Flags>(static_cast<uint32_t>(a) & b); \
}

enum class BlobResourceAccessFlagBits : uint32_t {
    kRead = 1u<<0,
    kWrite = 1u<<1,
    kAll = 0xffffffffu
};
MAKE_FLAGS(BlobResourceAccess)

#undef MAKE_FLAGS

MI_NAMESPACE_END
#endif //MIRENDERER_CORE_TYPES_H
